package com.silence.gmall.product.domain.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.repository.CrudRepository;
import com.silence.gmall.product.assembler.BaseCategory2Factory;
import com.silence.gmall.product.domain.entity.BaseCategory2;
import com.silence.gmall.product.domain.mapper.BaseCategory2Mapper;
import com.silence.gmall.product.domain.repository.BaseCategory2Repository;
import com.silence.gmall.product.dto.BaseCategory2Dto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author silence
 * @Description 针对表【base_category2(二级分类表)】的数据库操作Repository实现
 * @Date 2025-08-17 16:28:16
 */
@Slf4j
@Repository
@RequiredArgsConstructor
public class BaseCategory2RepositoryImpl extends CrudRepository<BaseCategory2Mapper, BaseCategory2>
    implements BaseCategory2Repository {

    /**
     * 二级分类工厂
     */
    private final BaseCategory2Factory baseCategory2Factory;

    /**
     * 根据一级分类ID查询所有二级分类
     *
     * @param category1Id 一级分类ID
     * @return 二级分类列表
     */
    @Override
    public List<BaseCategory2Dto> listBaseCategory2(String category1Id) {
        return baseCategory2Factory.categoryList2CategoryResVoList(list(new LambdaQueryWrapper<BaseCategory2>().eq(BaseCategory2::getCategory1Id, category1Id)));
    }
} 